Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Contents tab refreshing #4001

Merged
merged 1 commit into from
Jan 16, 2024

Conversation

HebaruSan
Copy link
Member

Problem

The Contents tab refreshes and shows the mod contents if you download a mod via the Download button or right click menu, but not if it is downloaded during installation.

Cause

Refreshing cache-related state (including the Contents tab) is handled (duplicatively) at the places where GUI stores or purges a mod, but when you install an uncached mod, it is downloaded and stored by ModuleInstaller, so GUI doesn't react.

This is a brittle approach because it has a many-to-many structure, where each place that deals with the cache must also handle all of the secondary consequences itself.

Changes

  • Now NetModuleCache has ModStored and ModPurged events that it fires whenever mods are stored or purged, including during mod installation. If all mods are purged, ModPurged's module parameter will be null.
  • The logic for reacting to cache changes is consolidated into one GUI.Main.OnModStoredOrPurged function, which is used to handle the new events, including during installation. Places that formerly triggered the refresh now no longer do, because they don't need to anymore.
  • UpdateCachedByDownloads can now handle updating the full mod list's IsCached property when its parameter is null, for when the user clears the cache in the settings
  • ManageMods.OnSelectedModuleChanged now no longer sets ModInfo's active mod when the Manage Mods tab is not active, for when OnModStoredOrPurged refilters the mod list in the background during installs, because this causes ModInfo to become visible when it shouldn't. It will still be set when the Manage Mods tab becomes active again.

Fixes #3998.

@HebaruSan HebaruSan added Bug Something is not working as intended GUI Issues affecting the interactive GUI labels Jan 16, 2024
@HebaruSan HebaruSan merged commit 1264e20 into KSP-CKAN:master Jan 16, 2024
8 checks passed
@HebaruSan HebaruSan deleted the fix/refresh-contents branch January 16, 2024 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended GUI Issues affecting the interactive GUI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After downloading and installing a mod for the first time, the "Contents" tab is not refreshed properly
1 participant